home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 13 / AMIGAplus Sonderheft 13 (1998)(ICP)(DE)[!].iso / rexx / install.rexx < prev    next >
OS/2 REXX Batch file  |  1996-03-13  |  13KB  |  474 lines

  1. /* Menus & More Installation Script for use with ARexx       */
  2. /*                                                           */
  3. /* $VER: Install.rexx 3.21 (13.03.96) by Axel Sodtalbers     */
  4. /*                                                           */
  5. /* PURPOSE: M&M installation routine;                        */
  6. /*          to be called from 'Install.M&M' project          */
  7. /*                                                           */
  8. /* 3.00 (11.02.95)  first release                            */
  9. /* 3.10 (19.02.95)  now correct directory name               */
  10. /* 3.20 (11.06.95)  correct assign statement in user-startup */
  11. /*                  Don't forget hint at the end             */
  12. /*                                                           */
  13. /* 3.21 (13.03.96)  | instead of ||                          */
  14. /*                  no more writing to S:user-startup        */
  15. /*                                                           */
  16. /* oh dear, what a strange language...                       */
  17. /*                                                           */
  18. /* Das deutsche ARexx Handbuch ist wirklich                  */
  19. /* DAS MIT ABSTAND MIESESTE EDV HANDBUCH                     */
  20. /* das ich JEMALS gelesen habe - wirklich unglaublich...     */
  21.  
  22.  
  23. /*** Init ***/
  24. OPTIONS RESULTS
  25. OPTIONS FAILAT 21
  26.  
  27. IF SHOW('P', 'MMPlayer') THEN
  28.    ADDRESS "MMPlayer"
  29.  
  30. 'AlohaPlayer'
  31. 'Query ISGERMAN'
  32. ger = RESULT
  33. oldstatus = ''
  34. lhaprg = "C:lha"
  35.  
  36. /*** fetch target directory ***/
  37. if ger then do
  38.     "Req 'Gleich erscheint ein Verzeichnis-Requester.||Bitte geben Sie dort an, in welchem||Verzeichnis das Unterverzeichnis M&M||für Menus&More angelegt werden soll!||(Die M&M-Dateien belegen ca. 1 MB)' 'Okay, klar zum Abheben!|Abbruch'"
  39.     if RESULT~=0 then do
  40.         RESULT=0  /* ?!? */
  41.         "ReqDir 'M&M installieren nach:' 'RAM:'"
  42.         if RESULT>0 then
  43.             target=RESULT
  44.         else
  45.             exit
  46.     end
  47.     else
  48.         exit
  49. end
  50. else do
  51.     "Req 'After this, a directory-requester will appear.||Please select, in which drawer||the sub-directory M&M shall be created!||(M&M needs about 930 KB of free disk space)' 'Okay, ready for take off!|Cancel'"
  52.     if RESULT~=0 then do
  53.         RESULT=0
  54.         "ReqDir 'Install M&M to:' 'RAM:'"
  55.         if RESULT>0 then
  56.             target=RESULT
  57.         else
  58.             exit
  59.     end
  60.     else
  61.         exit
  62. end
  63.  
  64. 'FileExists' target
  65. if RESULT=0 then do
  66.    if ger then do
  67.       "Req" "'Das angebene Verzeichnis||" || target || "||existiert nicht!||'" "'Verzeichnis erstellen|Abbrechen'"
  68.    end
  69.    else do
  70.       "Req" "'The given drawer||" || target || "||does not exist!||'" "'Create the drawer|Cancel'"
  71.    end
  72.  
  73.    if RESULT=1 then do
  74.       ADDRESS COMMAND MakeDir "> nil:" target
  75.       ADDRESS COMMAND "Copy MM:/M&M3.21.info to "||target||".info QUIET"
  76.    end
  77.    else do
  78.       exit
  79.    end
  80. end
  81.  
  82.  
  83. /*** check for M&M sub-directory ***/
  84.  
  85. MakeNewDir = 1
  86. if (right(target, 1) ~= ':') then
  87.    target = target || '/M&M'
  88. else
  89.    target=target || 'M&M'
  90.  
  91. 'FileExists' target
  92. if RESULT~=0 then do
  93.    if ger then
  94.       "Req" "'Hier existiert schon||ein M&M Unterverzeichnis!'" "'Alte Dateien überschreiben|Abbrechen'"
  95.    else
  96.       "Req" "'There is already||a M&M sub-directory!'" "'Overwrite old files|Cancel'"
  97.  
  98.    if RESULT=0 then
  99.       exit
  100.    else
  101.       MakeNewDir = 0
  102.  
  103. end
  104.  
  105. /*** build drawing area ***/
  106.  
  107. x=30
  108. y=150
  109. i=x+650
  110. k=y+70
  111.  
  112. 'DrawColor 0'
  113. 'DrawRectFill' x y i k
  114. 'DrawColor 1'
  115. if ger then
  116.    'DrawText 300, 162, "Erledigt:"'
  117. else
  118.    'DrawText 300, 162, "Progress:"'
  119.  
  120. 'DrawText 150, 195, "0%"'
  121. 'DrawText 520, 195, "100%"'
  122. call DrawShadow
  123.  
  124. x=150
  125. y=170
  126. i=560
  127. k=y+15
  128.  
  129. if MakeNewDir=1 then do
  130.    if ger then
  131.       Call StatusOut ("'Zielverzeichnis " || target || " erstellen...'")
  132.    else
  133.       Call StatusOut ("'Creating target directory " || target || "...'")
  134.  
  135.    ADDRESS COMMAND Makedir "> nil:" target
  136.    ADDRESS COMMAND "Copy MM:/M&M3.21.info to "||target||".info QUIET"
  137. end
  138. Call Complete (5)
  139.  
  140.  
  141. /*** copy and extract files ***/
  142.  
  143. copyDone=0
  144. Call CopyFile('MMEditor')
  145. if ~copyDone then
  146.    exit
  147. Call CopyFile('MMEditor.info')
  148. if copyDone then
  149.    Call Complete (20)
  150. else
  151.    exit
  152.  
  153. Call CopyFile('MMPlayer')
  154. if ~copyDone then
  155.    exit
  156. Call CopyFile('MMPlayer.info')
  157. if copyDone then
  158.    Call Complete (30)
  159. else
  160.    exit
  161.  
  162. Call CopyFile('M&M.guide')
  163. if ~copyDone then
  164.    exit
  165. Call CopyFile('M&M.guide.info')
  166. if copyDone then
  167.    Call Complete (40)
  168. else
  169.    exit
  170.  
  171. Call CopyFile('Tools')
  172. if ~copyDone then
  173.    exit
  174. Call CopyFile('Tools.info')
  175. if copyDone then
  176.    Call Complete (50)
  177. else
  178.    exit
  179.  
  180. Call CopyFile('Examples')
  181. if ~copyDone then
  182.    exit
  183. Call CopyFile('Examples.info')
  184. if copyDone then
  185.    Call Complete (70)
  186. else
  187.    exit
  188.  
  189. Call CopyFile('ARexx')
  190. if ~copyDone then
  191.    exit
  192. Call CopyFile('ARexx.info')
  193. if copyDone then
  194.    Call Complete (75)
  195. else
  196.    exit
  197.  
  198. Call CopyFile('M&M.config.info')
  199. if ~copyDone then
  200.    exit
  201. Call CopyFile('M&M.icon.info')
  202. if ~copyDone then
  203.    exit
  204. Call CopyFile('M&M.appicon.info')
  205. if copyDone then
  206.    Call Complete (77)
  207. else
  208.    exit
  209.  
  210. Call CopyFile('ReadMe.guide')
  211. if ~copyDone then
  212.    exit
  213. Call CopyFile('ReadMe.guide.info')
  214. if copyDone then
  215.    Call Complete (80)
  216. else
  217.    exit
  218.  
  219.  
  220. /*** german files ***/
  221. if ger then do
  222.     Call StatusOut ('"Deutschsprachige Kataloge kopieren..."')
  223.     'FileExists LOCALE:catalogs/deutsch'
  224.     if RESULT=0 then
  225.         'Req "Installation der deutsche Kataloge z.Zt. NICHT möglich!||Bitte nachholen - sonst keine deutsche Oberfläche!" "Jawoll, wird erledigt!"'
  226.     else do
  227.         ADDRESS COMMAND "Copy MM:deutsch/MMEditor.catalog to LOCALE:Catalogs/deutsch QUIET"
  228.         ADDRESS COMMAND "Copy MM:deutsch/MMPlayer.catalog to LOCALE:Catalogs/deutsch QUIET"
  229.     end
  230.     Call Complete (82)
  231.  
  232.     Call StatusOut ('"Deutschsprachige Dokumentation kopieren..."')
  233.     'Req "Soll AUCH die englische Dokumentation||kopiert werden?" "Jawohl!|Nein"'
  234.     if RESULT=0 then do
  235.         ADDRESS COMMAND Copy 'MM:M&MD.guide'      to target||'/M&M.guide'
  236.         ADDRESS COMMAND Copy 'MM:M&MD.guide.info' to target||'/M&M.guide.info'
  237.     end
  238.     else do
  239.         Call CopyFile('M&MD.guide')
  240.         if copyDone then do
  241.             Call CopyFile('M&MD.guide.info')
  242.             ADDRESS COMMAND Rename target||'/M&M.guide'       to target||'/M&ME.guide'
  243.             ADDRESS COMMAND Rename target||'/M&M.guide.info'  to target||'/M&ME.guide.info'
  244.             ADDRESS COMMAND Rename target||'/M&MD.guide'      to target||'/M&M.guide'
  245.             ADDRESS COMMAND Rename target||'/M&MD.guide.info' to target||'/M&M.guide.info'
  246.         end
  247.         else
  248.             exit
  249.     end
  250.     Call Complete (90)
  251. end
  252.  
  253. /*** old icons? ***/
  254. if ger then
  255.     'Req "Möchten Sie die normalen 4-farbigen oder||die 8-farbigen MagicWB Piktogramme benutzen?" "MagicWB|Normale"'
  256. else
  257.     'Req "Do you want to use the normal (4 colours) or||the MagicWB (8 colours) icons?" "MagicWB|Normal"'
  258. if RESULT=0 then do
  259.     ADDRESS COMMAND Copy 'MM:OldIcons/#?.info'          to target               ALL QUIET
  260.     ADDRESS COMMAND Copy 'MM:OldIcons/Examples/#?.info' to target||'/Examples/' ALL QUIET
  261.     ADDRESS COMMAND Copy 'MM:OldIcons/Tools/#?.info'    to target||'/Tools/'    ALL QUIET
  262.     ADDRESS COMMAND Copy 'MM:OldIcons/Examples.info'    to target||'.info'      ALL QUIET
  263. end
  264. Call Complete (94)
  265.  
  266. /*** this project ***/
  267. ADDRESS COMMAND Copy 'MM:Install.M&M' to target||'/Examples/' QUIET
  268.  
  269.  
  270. /*** Copying libraries ***/
  271. Call CopyLib ('ASL.library')
  272. Call Complete (95)
  273. Call CopyLib ('diskfont.library')
  274. Call Complete (96)
  275. Call CopyLib ('rexxsyslib.library')
  276. Call Complete (97)
  277. Call CopyLib ('AmigaGuide.library')
  278. Call Complete (98)
  279. Call CopyLib ('Locale.library')
  280.  
  281. /*** done! ***/
  282. Call Complete (100)
  283. if ger then
  284.     'Req "Okay, die Installation wurde||erfolgreich beendet!" "Na super!"'
  285. else
  286.     'Req "Okay, Installation has been||finished successfully!" "Well done!"'
  287.  
  288. 'LoadBrush "MM:Examples/Install_DontForget.pic"'
  289. 'PasteBrush 54, 153'
  290. 'FreeBrush'
  291.  
  292. Call StatusOut ('""')
  293. 'AlohaPlayer'
  294.  
  295. ADDRESS COMMAND "Assign MM: REMOVE"
  296. exit
  297.  
  298.  
  299.  
  300. /************************/
  301. /*                      */
  302. /* Subroutine: FileCopy */
  303. /*                      */
  304. /************************/
  305.  
  306. CopyFile:
  307.     parse arg file
  308.  
  309.     newtarget = target||"/"||file
  310.     if ger then
  311.        Call StatusOut ("'Kopiere "||file||" nach "||newtarget||"...'")
  312.     else
  313.        Call StatusOut ("'Copy "||file||" to "||newtarget||"...'")
  314.  
  315.     copyDone=1
  316.     do forever
  317.        ADDRESS COMMAND Copy ">NIL:" file newtarget "ALL QUIET"
  318.        if RC > 0 then do
  319.           if ger then
  320.              'Req "Kopieren ist fehlgeschlagen!" "Nochmal versuchen|Ignorieren|Abbrechen"'
  321.           else
  322.              'Req "Copy failed!" "Try again|Ignore|Cancel"'
  323.  
  324.           r=RESULT
  325.           if r=0 then do        /* cancel */
  326.              copyDone=0
  327.              leave
  328.           end
  329.           if r=2 then           /* ignore */
  330.              leave
  331.        end
  332.        else
  333.           leave
  334.     end
  335. return
  336.  
  337.  
  338. /*************************************/
  339. /*                                   */
  340. /* Subroutine: ExtractFiles - future */
  341. /*                                   */
  342. /*************************************/
  343.  
  344. ExtractFiles:
  345.     parse arg archive targetdir .
  346.  
  347.     do forever
  348.        'FileExists' lhaprg
  349.        if RESULT=0 then do
  350.           if ger then
  351.              'Req "Kann das Programm LhA nicht finden!" "LhA suchen|Abbrechen"'
  352.           else
  353.             'Req "Cannot find the LhA program!" "Search for it|Cancel"'
  354.  
  355.           r=RESULT
  356.           if r=0 then do        /* cancel */
  357.              extractDone=0
  358.              leave
  359.           end
  360.           else do
  361.              'ReqFile "LhA ???" "'||lhaprg||"'"
  362.              if RESULT>0 then
  363.                 lhaprg=RESULT
  364.           end
  365.        end
  366.        else
  367.           leave
  368.     end
  369.  
  370.     newtarget = target||"/"||targetdir||"/"
  371.     if ger then
  372.        Call StatusOut ("'Extrahiere "||archive||" nach "||newtarget||"...'")
  373.     else
  374.        Call StatusOut ("'Extracting "||archive||" to "||newtarget||"...'")
  375.  
  376.     extractDone=1
  377.     do forever
  378.        ADDRESS COMMAND lhaprg "-q x" archive newtarget
  379.        if RC > 0 then do
  380.           if ger then
  381.              'Req "Extrahieren des Archivs ist fehlgeschlagen!" "Nochmal versuchen|Ignorieren|Abbrechen"'
  382.           else
  383.              'Req "Extracting from Archive failed!" "Try again|Ignore|Cancel"'
  384.  
  385.           r=RESULT
  386.           if r=0 then do        /* cancel */
  387.              extractDone=0
  388.              leave
  389.           end
  390.           if r=2 then           /* ignore */
  391.              leave
  392.        end
  393.        else
  394.           leave
  395.     end
  396. return
  397.  
  398. /****************************/
  399. /*                          */
  400. /* Subroutine: Library Copy */
  401. /*                          */
  402. /****************************/
  403.  
  404. CopyLib:
  405.     parse arg lib
  406.  
  407.     if ger then
  408.         Call StatusOut ("'Teste "||lib||"...'")
  409.     else
  410.         Call StatusOut ("'Checking "||lib||"...'")
  411.  
  412.     'FileExists' 'LIBS:'||lib
  413.     if RESULT=0 then do
  414.         if ger then
  415.             "Req" "'Die Library||"||lib||"||existiert nicht! Bitte original Workbench-Disk||in Laufwerk DF0: einlegen!'" "'Weiter|Ignorieren'"
  416.         else
  417.             "Req" "'The"||lib|| "||does not exist!||Please insert original Workbench-Disk into DF0:!'" "'Go on|Ignore'"
  418.  
  419.         do while (RESULT~=0)
  420.             if ger then
  421.                Call StatusOut ("'Kopiere DF0:Libs/"||lib||" nach LIBS: ...'")
  422.             else
  423.                Call StatusOut ("'Copy DF0:Libs/"||lib||" to LIBS: ...'")
  424.  
  425.             ADDRESS COMMAND "Copy DF0:Libs/"||lib||" to LIBS: QUIET"
  426.             if RC>0 then do
  427.                 if ger then
  428.                     "Req" "'Kopieren ist fehlgeschlagen!||'" "'Nochmal versuchen|Ignorieren'"
  429.                 else
  430.                     "Req" "'Copy failed!||'" "'Try again|Ignore'"
  431.             end
  432.         end
  433.     end
  434. return
  435.  
  436.  
  437. StatusOut:                              /* what is done currently */
  438.     procedure expose oldstatus
  439.     parse arg status
  440.     'DrawColor 0'
  441.     'DrawText 50, 210,' oldstatus
  442.     oldstatus = status
  443.     'DrawColor 6'
  444.     'DrawText 50, 210,' status
  445. return
  446.  
  447.  
  448. Complete:                               /* completage display */
  449.     parse arg percentage
  450.     'DrawColor 1'
  451.  
  452.     oldi = i; i = x + ((i-x)%100*percentage)
  453.  
  454.     'DrawRectFill' x y i k
  455.     call DrawShadow
  456.     i=oldi
  457. return
  458.  
  459.  
  460. DrawShadow:                             /* paint a shadow effect */
  461.     'DrawColor 2'                       /* white */
  462.     'DrawLine' x k x y
  463.     'DrawLine' x+1 k x+1 y+1
  464.     'DrawLine' x y i y
  465.  
  466.     'DrawColor 3'                       /* black */
  467.     'DrawLine' i y i k
  468.     'DrawLine' i-1 y+1 i-1 k
  469.     'DrawLine' i k x+1 k
  470. return
  471.  
  472.  
  473.  
  474.